package com.example.my_music_palyer.service;

import com.example.my_music_palyer.mapper.MusicMapper;
import com.example.my_music_palyer.model.Music;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MusicService {
    @Autowired
    MusicMapper musicMapper;

    public int insert(String title, String singer, String time, String url,int userid, int status){
       return musicMapper.insert(title,singer,time,url,userid,status);
    }

    public Music isSymple(String title, String singer) {
        return musicMapper.isSymple(title,singer);
    }

    public Music findMusicById(int id){
        return musicMapper.findMusicById(id);
    }

    public int deleteMusicById(int id){
        return musicMapper.deleteMusicById(id);
    }

    public List<Music> findMusicByMusicName(String musicName){
        return musicMapper.findMusicByMusicName(musicName);
    }

    public List<Music> findMusic(){
        return musicMapper.findMusic();
    }

    // 普通用户：可见已上架，或本人上传且审核中
    public List<Music> findMusicForUser(int userId){
        return musicMapper.findMusicForUser(userId);
    }

    public List<Music> findAllMusic(){
        return musicMapper.findAllMusic();
    }

    public List<Music> findAllMusicByMusicName(String musicName){
        return musicMapper.findAllMusicByMusicName(musicName);
    }

    // 普通用户关键词查询：可见已上架，或本人上传且审核中
    public List<Music> findMusicByMusicNameForUser(int userId, String musicName){
        return musicMapper.findMusicByMusicNameForUser(userId, musicName);
    }

    public int updateMusicStatus(int id, int status){
        return musicMapper.updateMusicStatus(id, status);
    }

    public Music findByUrl(String url){
        return musicMapper.findByUrl(url);
    }
}
